<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header">
</head>
<body class="gray-bg">
<!--<div id="div1" class="container-div" style="height:auto ">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <iframe
                    id="ifm1"
                    width="100%" height="350"
                    frameborder="0" name="todolist"
                    scrolling="auto"
            ></iframe>
        </div>
    </div>
</div>-->


<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            标题：<input type="text" name="jtTitle"/>
                        </li>

                        <li>
                            内容：<input type="text" name="jtDetails"/>
                        </li>

                        <!--<li class="select-time">
                        <label>变更日期： </label>
                        <input type="text" class="time-input" id="bg_startTime" placeholder="开始时间"
                        name="params[beginTime1]"/>
                        <span>-</span>
                        <input type="text" class="time-input" id="bg_endTime" placeholder="结束时间"
                        name="params[endTime1]"/>
                        </li>-->

                        <li class="select-time">
                            <label>录入日期： </label>
                            <input type="text" class="time-input" id="startTime" placeholder="开始时间"
                                   name="params[beginTime1]"/>
                            <span>-</span>
                            <input type="text" class="time-input" id="endTime" placeholder="结束时间"
                                   name="params[endTime1]"/>
                        </li>

                        <!--  <li>
                          图片：
                          <select name="jtProcess" th:with="type=${@dict.getType('sys_map_status')}">
                          <option value="">所有</option>
                          <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                          th:value="${dict.dictValue}"></option>
                          </select>
                          </li>

                          <li>
                          审批状态：
                          <select name="jtStatus" th:with="type=${@dict.getType('sys_approval_status')}">
                          <option value="">所有</option>
                          <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                          th:value="${dict.dictValue}"></option>
                          </select>
                          </li>-->


                          <li>
                          类别：<select id="category1" name="jtLb1id"
                          data-rel="chosen">
                          <option value="">全部分类</option>
                          </select>
                          <select name="jtLb2id" id="category2"
                          data-rel="chosen">
                          <option value="">全部分类</option>
                          </select>
                          <select name="jtLb3id" id="category3"
                          data-rel="chosen">
                          <option value="">全部分类</option>
                          </select>

                          </li>
                          <!-- <li>
                           二级类别：
                           <select name="jtLb2id" id="category2"
                           data-rel="chosen">
                           <option value="">全部分类</option>
                           </select>
                           </li>
                           <li>
                           三级类别：
                           <select name="jtLb3id" id="category3"
                           data-rel="chosen">
                           <option value="">全部分类</option>
                           </select>
                           </li>-->
                         <li>
                         地域：<select id="area1" name="jtProvinceid"
                         data-rel="chosen">
                         <option value="">全部省</option>
                         </select>
                         <select name="jtCityid" id="area2"
                         data-rel="chosen">
                         <option value="">全部市</option>
                         </select>
                         <select name="jtCountryid" id="area3"
                         data-rel="chosen">
                         <option value="">全部县</option>
                         </select>
                         </li>
<!--                         <li>-->
<!--                          选择市：-->
<!--                          <select name="jtCityid" id="area2"-->
<!--                          data-rel="chosen">-->
<!--                          <option value="">全部市</option>-->
<!--                          </select>-->
<!--                          </li>-->
<!--                          <li>-->
<!--                          选择县：-->
<!--                          <select name="jtCountryid" id="area3"-->
<!--                          data-rel="chosen">-->
<!--                          <option value="">全部县</option>-->
<!--                          </select>-->
<!--                          </li>-->

                         <li>
                             <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                     class="fa fa-search"></i>&nbsp;搜索</a>
                             <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                     class="fa fa-refresh"></i>&nbsp;重置</a>
                             <!--<a class="btn btn-success btn-rounded btn-sm" onclick="displaydata()"><i
                                     class="fa fa-sort-amount-asc"></i>&nbsp;展示/隐藏参考数据</a>-->
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:jiaotong:add">
                <i class="fa fa-plus"></i> 添加
            </a>
            <a class="btn btn-primary btn-edit disabled" id="xiugai" onclick="$.operate.edit()"
               shiro:hasPermission="system:jiaotong:edit">
                <i class="fa fa-edit"></i> 修改
            </a>
            <a class="btn btn-danger btn-del btn-del disabled" id="shanchu" onclick="$.operate.removeAll()"
               shiro:hasPermission="system:jiaotong:remove">
                <i class="fa fa-remove"></i> 删除
            </a>
            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:jiaotong:export">
                <i class="fa fa-download"></i> 导出
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table" data-mobile-responsive="true"></table>
        </div>
    </div>
</div>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('system:jiaotong:edit')}]];
    var removeFlag = [[${@permission.hasPermi('system:jiaotong:remove')}]];
    var infoFlag = [[${@permission.hasPermi('system:jiaotong:info')}]];
    var shenpiFlag = [[${@permission.hasPermi('system:jiaotong:shenpi')}]];
    var avatarFlag = [[${@permission.hasPermi('system:jiaotong:avatar')}]];

    var qxg = [[${@permission.hasPermi('system:qxg:edit')}]];
    var yxg = [[${@permission.hasPermi('system:yxg:edit')}]];
    var ysh = [[${@permission.hasPermi('system:ysh:edit')}]];

    var prefix = ctx + "system/jiaotong";
    var prefix1 = ctx + "system/category";
    var prefix2 = ctx + "system/area";

     var jtRoleName = '';
    $(function () {
        initCategrey();
        initArea();
        displaydata();
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            infoUrl: prefix + "/info/{id}",
            shenpiUrl: prefix + "/shenpi/{id}",
            avatarUrl: prefix + "/avatar/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "交通",
            showExport: true,
            search: false,
            sortName: 'createTime',
            sortOrder: 'desc',
            onLoadSuccess: function (data) {
                mysetAction();
               // alert(jtRoleName)
                if(jtRoleName=='信息员') {
                    $('#xiugai').remove();
                    $('#shanchu').remove();
                }
            },
            columns: [{
                checkbox: true
            },
                {
                    field: 'jtId',
                    title: '交通',
                    visible: false
                },
                {
                    field: 'jtTitle',
                    title: '标题',
                    sortable: true
                },
                // {
                //     field: 'jtChangedate',
                //     title: '变更日期',
                //     sortable: true,
                //     formatter: function (value, row, index) {
                //         return dateFtt(value)
                //     }
                // },
                {
                    field: 'createTime',
                    title: '录入日期',
                    sortable: true
                },
                {
                    field: 'updateTime',
                    title: '更新日期',
                    sortable: true
                },
                {
                    field: 'jtProcess',
                    title: '图片',
                    sortable: true,
                    formatter: function (value, row, index) {
                        if (row.jtProcess == '已上传') {
                            return '<a href="#" onclick="avatarinfo(\'' + row.jtId + '\')">' + value + '</a>';
                        }
                        else {
                            return row.jtProcess;
                        }
                    }
                },
                {
                    field: 'jtStatus',
                    title: '审批状态',
                    sortable: true,
                    formatter: function (value, row, index) {
                        if (row.jtStatus == '驳回') {
                            return '<a href="#" onclick="shenpiinfo(\'' + row.jtId + '\')">' + value + '</a>';
                        }
                        else {
                            return row.jtStatus;
                        }
                    }
                },
                {
                    field: 'jt_ck',
                    title: '地图院数据库审批',
                    sortable: true,
                    formatter: function (value, row, index) {
                        return mySetBtns(value, row, index, 'jtId', 1, qxg, yxg, ysh);
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        jtRoleName = row.jtRoleName;
                        var actions = [];
                        actions.push('<a id="test" class="btn btn-info btn-xs ' + infoFlag + '" href="#" onclick="$.operate.info(\'' + row.jtId + '\')"><i class="fa fa-info"></i>快速预览</a> ');
                        if (row.jtRoleName == '管理员') {
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="$.operate.edit(\'' + row.jtId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        }
                        else {
                            if (row.jtStatus == '审批通过') {

                            }
                            else {
                                actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="$.operate.edit(\'' + row.jtId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                            }
                        }
                        actions.push('<a class="btn btn-info btn-xs ' + avatarFlag + '" href="#" onclick="avatar(\'' + row.jtId + '\')"><i class="fa fa-info"></i>图面化</a> ');
                        actions.push('<a class="btn btn-info btn-xs ' + shenpiFlag + '" href="#" onclick="shenpi(\'' + row.jtId + '\')"><i class="fa fa-info"></i>审批</a> ');
                        if (row.jtRoleName == '管理员') {
                            actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#" onclick="$.operate.remove(\'' + row.jtId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        }
                        else {
                            if (row.jtStatus == '审批通过') {

                            }
                            else {
                                actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#" onclick="$.operate.remove(\'' + row.jtId + '\')"><i class="fa fa-remove"></i>删除</a>');
                            }
                        }
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    function displaydata1() {
        $("#div1").hide();
    }

    function displaydata() {
        if ($('#div1').is(':hidden')) {

            $("#div1").show();
            //setIframeHeight("ifm1");
            if(!$('#ifm1').attr("src"))
            $('#ifm1').attr('src', dashuju + '/out/cmsInfoDetail');
        }
        else {

            $("#div1").hide();
        }
    }

    // function ck()
    // {
    // 	$("#ck1").click(function()
    // 	{
    // 		$('#ck2'). removeAttr('disabled');
    // 	})
    // 	// if($("#ck1").is(":checked"))
    // 	// {
    // 	// 	$("#div1").show();
    // 	// 	$("[name=check2]:checkbox").prop("checked", true);
    // 	// 	if($("#ck2").is(":checked"))
    // 	// 	{
    // 	// 		 $("[name=check3]:checkbox").prop("checked", true);
    // 	// 	}
    // 	// }
    // }

    function setIframeHeight(iframeId) {
        var cwin = document.getElementById(iframeId);
        if (document.getElementById) {
            if (cwin && !window.opera) {
                if (cwin.contentDocument && cwin.contentDocument.body.offsetHeight) {
                    cwin.height = cwin.contentDocument.body.offsetHeight + 20; //FF NS
                }
                else if (cwin.Document && cwin.Document.body.scrollHeight) {
                    cwin.height = cwin.Document.body.scrollHeight + 10;//IE
                }
            } else {
                if (cwin.contentWindow.document && cwin.contentWindow.document.body.scrollHeight)
                    cwin.height = cwin.contentWindow.document.body.scrollHeight;//Opera
            }
        }
    };

    function avatar(jtId) {
        var url = prefix + '/avatar/' + jtId;
        $.modal.open("图面化操作", url);
    }

    function shenpi(jtId) {
        var url = prefix + '/shenpi/' + jtId;
        $.modal.open("审批操作", url);
    }

    function shenpiinfo(jtId) {
        var url = prefix + '/shenpiinfo/' + jtId;
        $.modal.open("审批意见", url);
    }

    function avatarinfo(jtId) {
        var url = prefix + '/avatarinfo/' + jtId;
        $.modal.open("图片预览", url);
    }

    function initCategrey() {


        cate1();
        cate2();
        $("#category1").change(function () {
            cate2();

        });
        $("#category2").change(function () {
            if($("#category2").val()==0)
            {
                cate31();
            }
            else
            {
                cate3($("#category2").val());
            }
        });

    }

    function cate1() {
        $.get(
            prefix1 + "/list?parentId=100&deptId=101",
            function (data) {
                if (data) {
                    var result = "";
                    $.each(data, function (n, value) {
                        result += "<option value='" + value.deptId + "'>" + value.deptName + "</option>";
                    });
                    $("#category1").html(result);
                }
            }, "json");
    }
    function cate31() {
        $.get(
            prefix1 + "/list?parentId=301",
            function (data) {
                if (data) {
                    $("#category3").html("<option value=''>全部分类</option>");
                }
            }, "json");
    }


    function cate2() {
        $.get(
            prefix1 + "/list?parentId=101",
            function (data) {
                if (data) {
                    $("#category2").html("<option value=''>全部分类</option>");
                    var result = "<option value=''>全部分类</option>";
                    $.each(data, function (n, value) {

                        // if (n == 0) {
                        //     cate3(value.deptId);
                        // }
                        result += "<option value='" + value.deptId + "'>" + value.deptName + "</option>";
                    });
                    $("#category2").html(result);


                }
            }, "json");
    }

    function cate3(id) {
        $.get(
            prefix1 + "/list?parentId=" + id,
            function (data) {
                $("#category3").html("<option value=''>全部分类</option>");
                if (data) {
                    var result = "<option value=''>全部分类</option>";

                    $.each(data, function (n, value) {
                        result += "<option value='" + value.deptId + "'>" + value.deptName + "</option>";
                    });

                    $("#category3").html(result);
                }
            }, "json");
    }

    function initArea() {
        $.get(
            prefix2 + "/list?parentId=1",
            function (data) {
                if (data) {
                    var result = "<option value=''>全部省</option>";
                    $.each(data, function (n, value) {
                        result += "<option value='" + value.deptId + "'>" + value.deptName + "</option>";
                    });
                    $("#area1").html(result);
                }
            }, "json");


        $("#area1").change(function () {
            getAreaValue();
            if($("#area1").val()==0)
            {
                $.get(
                    prefix2 + "/list?parentId=" + $("#area1").val(),
                    function (data) {
                        $("#area2").html("<option value=''>全部市</option>");
                    }, "json");
                $.get(
                    prefix2 + "/list?parentId=" + $("#area2").val(),
                    function (data) {
                        $("#area3").html("<option value=''>全部县</option>");
                    }, "json");
            }
            else
            {
                $.get(
                    prefix2 + "/list?parentId=" + $("#area1").val(),
                    function (data) {
                        $("#area2").html("<option value=''>全部市</option>");
                        if (data) {
                            var result = "<option value=''>全部市</option>";
                            $.each(data, function (n, value) {
                                result += "<option value='" + value.deptId + "'>" + value.deptName + "</option>";
                            });
                            $("#area2").html(result);
                        }
                    }, "json");

                if($("#area2").val()==0)
                {
                    $.get(
                        prefix2 + "/list?parentId=" + $("#area2").val(),
                        function (data) {
                            $("#area3").html("<option value=''>全部县</option>");
                        }, "json");
                }
                else
                {
                    $.get(
                        prefix2 + "/list?parentId=" + $("#area2").val(),
                        function (data) {
                            $("#area3").html("<option value=''>全部县</option>");
                            if (data) {
                                var result = "<option value=''>全部县</option>";
                                $.each(data, function (n, value) {
                                    result += "<option value='" + value.deptId + "'>" + value.deptName + "</option>";
                                });

                                $("#area3").html(result);
                            }
                        }, "json");
                }
            }
        });
        $("#area2").change(function () {
            getAreaValue();
            if($("#area2").val()==0)
            {
                $.get(
                    prefix2 + "/list?parentId=" + $("#area2").val(),
                    function (data) {
                        $("#area3").html("<option value=''>全部县</option>");
                    }, "json");
            }
            else
            {
                $.get(
                    prefix2 + "/list?parentId=" + $("#area2").val(),
                    function (data) {
                        $("#area3").html("<option value=''>全部县</option>");
                        if (data) {
                            var result = "<option value=''>全部县</option>";
                            $.each(data, function (n, value) {
                                result += "<option value='" + value.deptId + "'>" + value.deptName + "</option>";
                            });

                            $("#area3").html(result);
                        }
                    }, "json");
            }
        });

        $("#area3").change(function () {
            getAreaValue();
        });
    }

    function getAreaValue() {
        var c1 = $("#area1").val()
        var c2 = $("#area2").val()
        var c3 = $("#area3").val()

        console.log('**********: c1:' + c1 + ',' + 'c2:' + c2 + ',' + 'c3:' + c3);

    }

</script>
</body>
</html>